package me.zhengjie.modules.quartz.service.dto

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeName
import me.zhengjie.common.annotation.Query
import me.zhengjie.common.utils.JacksonUtil
import me.zhengjie.modules.system.domain.Area
import org.apache.commons.lang3.builder.ToStringBuilder
import java.sql.Timestamp
/**
 * @author Kuki Wu
 * @date 2019-6-4 10:33:02
 */
@JsonTypeName("JobQueryCriteria")
data class JobQueryCriteria (
    @Query(type = Query.Type.INNER_LIKE)
    var jobName: String? = null,

    @Query
    var isSuccess: Boolean? = null,

    @Query(type = Query.Type.GREATER_THAN, propName = "createTime")
    var startTime: Timestamp? = null,

    @Query(type = Query.Type.LESS_THAN, propName = "createTime")
    var endTime: Timestamp? = null,

    @Query(type = Query.Type.BETWEEN)
    var createTime: List<Timestamp>? = null
){
    annotation class Update

    companion object {
        fun fromJson(json: String): Area? {
            val obj=JacksonUtil.parseObject(json, Area::class.java)!!
            return when(obj){
                is Area -> obj
                else -> null
            }
        }
    }

    fun tojson():String? {
        return JacksonUtil.toJSONString(this)
    }

    fun copy(source: JobQueryCriteria?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}